<html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- jQuery -->
    <script type="text/javascript" src="../../js/jquery-1.11.0.min.js"></script>
    <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
    <script src="../../js/getParameter.js"></script>

    <!-- Bootstrap -->
    <link href="../../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="../../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

    <style type="text/css">
        th {
            text-align: center;
        }

        td {
            text-align: center;
        }

        .row-margin-top {
            margin-top: 5px;
        }

        p {
            font-family: 微软雅黑;
            font-size: large;
            color: black;
        }
    </style>
    <script>
        function update_ticket(id) {
            alert(111)
            if (window.confirm("你是不是要退票")) {
                $.ajax({
                    url: "../../refund/updateTicket",
                    type: "post",
                    data:{"id":id},
                })
                load_04(1, 4, null)
            }
        }
        function load_04(currentPage, rows, select_input) {

            $.ajax({
                type: "post",
                url: "../../refund/seeTicket",
                data: {"currentPage": currentPage, "rows": rows, "select_input": select_input},
                success: function (data) {
                    var ticket_table = '';
                    ticket_table += ' <table id="ticket_table" class="table table-bordered table-striped">\n' +
                        '                    <thead>\n' +
                        '                    <tr>\n' +
                        '                        <th>电影票ID</th>\n' +
                        '                        <th>演出计划ID</th>\n' +
                        '                        <th>影厅ID</th>\n' +
                        '                        <th>座位ID</th>\n' +
                        '                        <th>生成票时间</th>\n' +
                        '                        <th>票价(元)</th>\n' +
                        '                        <th>电影票状态</th>\n' +
                        '                        <th>退票</th>\n' +
                        '                    </tr>\n' +
                        '                    </thead>';


                    $.each(data.list, function (ind, ele) {

                        var hei = null;
                        if (ele.ticketStatus == 0) {
                            hei = "正在观看"
                        }
                        if (ele.ticketStatus == -1) {
                            hei = "已观看"
                        }


                        if (ele.ticketStatus == 1 || select_input == null) {
                            hei = "还未观看"
                            ticketId_inp = ele.ticketId;

                            ticket_table += '<tr>\n' +
                                '                        <th>'+ele.ticketId+'</th>\n' +
                                '                        <th>'+ele.scheduleId+'</th>\n' +
                                '                        <th>'+ele.studioId+'</th>\n' +
                                '                        <th>'+ele.seatId+'</th>\n' +
                                '                        <th>'+ele.ticketTime+'</th>\n' +
                                '                        <th>'+ele.ticketPrice+'</th>\n' +
                                '                        <th>'+hei+'</th>\n' +
                                '                        <th>\n' +
                                '                            <button type="button" class="btn btn-primary" onclick="javascript:update_ticket('+ele.ticketId+')" id="play_update_btn">退票</button>\n' +
                                '                        </th>';

                        }


                    })
                    $("#ticket_table").html(ticket_table);


                    var prePage = currentPage - 1;
                    if (prePage < 1) {
                        prePage = 1
                    }
                    var afterPage = currentPage + 1;
                    if (afterPage > data.totalPage) {
                        afterPage = data.totalPage
                    }
                    var ticket_ul = '';


                    ticket_ul += '<li><a href="javascript:load_04(1,' + rows + ',' + select_input + ')">首页</a></li>';
                    ticket_ul += '<li class="threeword"><a href="javascript:load_04(' + prePage + ',' + rows + ',' + select_input + ')">上一页</a></li>';


                    var beginPage = 0;
                    var endPage = 0;
                    if (data.totalPage <= 10) {
                        beginPage = 1;
                        endPage = data.totalPage
                    } else {
                        if (currentPage - 5 <= 1) {
                            beginPage = 1;
                            endPage = beginPage + 9;
                        }
                        if (currentPage - 5 > 1) {
                            beginPage = currentPage - 5;
                            endPage = currentPage + 4;
                            if (endPage >= data.totalPage) {
                                endPage = data.totalPage;
                                beginPage = endPage - 9;
                            }
                        }
                    }
                    for (var i = beginPage; i <= endPage; i++) {
                        // rotte_pageBean_ul+='<li><a href="#">'+i+'</a></li>';
                        if (currentPage == i) {
                            ticket_ul += '<li class="curPage" id="curPage_ul"  onclick="load_04(' + i + ',' + rows + ',' + select_input + ')"><a href="javascript:load_04(' + i + ',' + rows + ',' + select_input + ')">' + i + '</a></li>';

                        } else {

                            ticket_ul += '<li  onclick="load_04(' + i + ',' + rows + ',' + select_input + ')"><a href="javascript:load_04(' + i + ',' + rows + ',' + select_input + ')">' + i + '</a></li>';
                        }

                    }
                    ticket_ul += '<li class="threeword"><a href="javascript:load_04(' + afterPage + ',' + rows + ',' + select_input + ');">下一页</a></li>';
                    ticket_ul += '<li class="threeword"><a href="javascript:load_04(' + data.totalPage + ',' + rows + ',' + select_input + ');">末页</a></li>';
                    $("#ticket_ul").html(ticket_ul);







                },
                dataType: "json"


            })


        };


        $(function () {


            $("#select_button").click(function () {
                // alert(111)
                var select_input = $("#select_input").val();
                load_04(1, 4, select_input);
            })


            var select_input = getParameter("select_input")

            load_04(1, 4, select_input);
        })
    </script>
</head>
<body>


<!--页面主体-->
<div class="container-fluid">
    <div class="row row-margin-top">
        <div class="col-md-12">

            <div class="row row-margin-top">
                <div class="col-md-8">
                    <div class="col-md-4">
                        <input type="text" class="form-control" id="select_input" placeholder="请 输 入 电 影 票 I D"
                               name="ticketId">
                        <span class="help-block"></span>
                    </div>

                    <div class="col-md-1">
                        <button id="select_button" class="btn btn-success btn-sm"><span
                                class="glyphicon glyphicon-search" aria-hidden="true"></span>搜索
                        </button>
                    </div>

                </div>

            </div>

            <div class="row">
                <div class="col-md-3 col-md-offset-5">
                    <h1>退票</h1>
                </div>
            </div>

            <div class="row row-margin-top">
                <div class="col-md-12">
                    <div class="col-md-1 col-md-offset-10">
                        <!--<button id="refundBtn" class="btn btn-warning btn-sm"><span class="glyphicon   glyphicon-yen"-->
                                                                                    <!--aria-hidden="true"></span>退票-->
                        <!--</button>-->
                    </div>

                    <div class="col-md-1">
                        <!--<button id="delBtn" class="btn btn-danger btn-sm"><span class="glyphicon  glyphicon-trash"-->
                                                                                <!--aria-hidden="true"></span>删除-->
                        <!--</button>-->
                    </div>

                </div>
            </div>

            <div class="row row-margin-top">
                <table id="ticket_table" class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>电影票ID</th>
                        <th>演出计划ID</th>
                        <th>影厅ID</th>
                        <th>座位ID</th>
                        <th>生成票时间</th>
                        <th>票价(元)</th>
                        <th>电影票状态</th>
                        <th>退票</th>
                    </tr>
                    </thead>

                </table>
                <ul class="pagination" id="ticket_ul">


                </ul>
            </div>
        </div>
    </div>

    <div class="row row-margin-top">
        <!-- 分页条信息 -->
        <div id="page_nav" class="col-md-4 col-md-offset-4">
        </div>
    </div>
    <!-- 显示分页信息 -->
    <div class="row row-margin-top">
        <!--分页文字信息  -->
        <div id="page_info" class="col-md-4 col-md-offset-4">
        </div>
    </div>
</div>
</body>
</html>